找传奇、传世资源到传世资源站!

基于m5310A,lwm2m协议通讯

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

官方例程

int main( int argc, char *argv[] ){ int life_time = 1000; int ret; nbiot_init_environment( argc, argv ); #ifdef NOTIFY_ACK ret = nbiot_device_create( &dev, life_time, write_callback, read_callback, execute_callback, notify_ack_callback );#else ret = nbiot_device_create( &dev, life_time, write_callback, read_callback, execute_callback );#endif if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(/3200/0/5750) failed, code = %d.\r\n", ret ); }LED.type = NBIOT_BOOLEAN; LED.flag = NBIOT_READABLE|NBIOT_WRITABLE; ret = nbiot_resource_add( dev, 3311, 0, 5850, &LED );//灯控制 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(LED) failed, code = %d.\r\n", ret ); } temp.type = NBIOT_FLOAT; temp.flag = NBIOT_READABLE; ret = nbiot_resource_add( dev, 3303, 0, 5700, &temp );//温度 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(temp) failed, code = %d.\r\n", ret ); } humi.type = NBIOT_FLOAT; humi.flag = NBIOT_READABLE; ret = nbiot_resource_add( dev, 3304, 0, 5700, &humi );//湿度 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(humi) failed, code = %d.\r\n", ret ); } illumi.type = NBIOT_FLOAT; illumi.flag = NBIOT_READABLE; ret = nbiot_resource_add( dev, 3301, 0, 5700, &illumi );//光照 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(illumi) failed, code = %d.\r\n", ret ); }/* press.type = NBIOT_FLOAT; press.flag = NBIOT_READABLE; ret = nbiot_resource_add( dev, 3202, 3, 5600, &press );//压力 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(press) failed, code = %d.\r\n", ret ); } altitude.type = NBIOT_FLOAT; altitude.flag = NBIOT_READABLE; ret = nbiot_resource_add( dev, 3202, 4, 5600, &altitude );//海拔 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(temp) failed, code = %d.\r\n", ret ); } acceleX.type = NBIOT_FLOAT; acceleX.flag = NBIOT_READABLE; ret = nbiot_resource_add( dev, 3202, 5, 5600, &acceleX );//x轴 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(acceleX) failed, code = %d.\r\n", ret ); }acceleY.type = NBIOT_FLOAT; acceleY.flag = NBIOT_READABLE; ret = nbiot_resource_add( dev, 3202, 6, 5600, &acceleY );//y轴 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(acceleY) failed, code = %d.\r\n", ret ); }acceleZ.type = NBIOT_FLOAT; acceleZ.flag = NBIOT_READABLE; ret = nbiot_resource_add( dev, 3202, 7, 5600, &acceleZ );//z轴 if ( ret ) { nbiot_device_destroy( dev ); printf( "device add resource(acceleZ) failed, code = %d.\r\n", ret ); }*/ nbiot_object_add(dev); ret = nbiot_device_connect(dev,100); if ( ret ) { printf( "connect OneNET failed.\r\n" ); nbiot_reset(); }else{ // Led4_Set(LED_ON); printf( "connect OneNET success.\r\n" ); } do { ret = nbiot_device_step( dev, 1); if ( ret ) { printf( "device step error, code = %d.\r\n", ret ); Led4_Set(LED_OFF); printf( "connect server failed.\r\n" ); nbiot_reset(); }else{ res_update(100); } } while(1); nbiot_clear_environment(); // getchar(); printf( "press enter key to exit..." ); return 0;}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复